<template>
  <div>
    {{$route.query.id}}
      <el-form ref="form" :model="formData" size="medium" label-width="110px">
        <el-row>
          <el-col :span="12">
            <el-form-item label="机构编码" prop="orgno" >
              <el-input v-model="formData.orgNo" clearable :style="{width: '100%'}" :disabled="b_disable"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="机构代码" prop="orgcode">
              <el-input v-model="formData.orgCode" clearable :style="{width: '100%'} " :disabled="b_disable"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="机构名称" prop="orgname">
              <el-input v-model="formData.orgName" clearable :style="{width: '100%'}" :disabled="b_disable"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label-width="99px" label="行政类别" prop="exetype">
              <el-radio-group v-model="formData.exeType" size="medium">
                <el-radio v-for="(item, index) in adType" :key="index" :label="item.value"
                          :disabled="b_disable">{{item.label}}</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="16">
            <el-form-item label="地址" prop="linkadd">
              <el-input v-model="formData.linkAdd" clearable :style="{width: '100%'}" :disabled="b_disable"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="邮编" prop="areacode">
              <el-input v-model="formData.areaCode" clearable :style="{width: '100%'}" :disabled="b_disable"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="挂牌日期" prop="listingdate">
              <el-date-picker v-model="formData.listingDate" format="yyyy-MM-dd" value-format="yyyy-MM-dd"
                              :style="{width: '100%'}" clearable :disabled="b_disable"></el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="独立运行日期" prop="standalonedate">
              <el-date-picker v-model="formData.standaloneDate" format="yyyy-MM-dd" value-format="yyyy-MM-dd"
                              :style="{width: '100%'}" clearable :disabled="b_disable"></el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="编办批文日期" prop="zbbdocDate">
              <el-date-picker v-model="formData.zbbdocDate" format="yyyy-MM-dd" value-format="yyyy-MM-dd"
                              :style="{width: '100%'}" clearable :disabled="b_disable"></el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="行政区类别" prop="areatype">
              <el-radio-group v-model="formData.areaType" size="medium">
                <el-radio v-for="(item, index) in areaType" :key="index" :label="item.value"
                          :disabled="b_disable">{{item.label}}</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="在职人数" prop="onworkernum">
              <el-input v-model="formData.onworkerNum" clearable :style="{width: '100%'}" :disabled="b_disable"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="卫生监督员数" prop="supervisornum">
              <el-input v-model="formData.supervisorNum" clearable :style="{width: '100%'}" :disabled="b_disable"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="机构行政级别" prop="orglevel">
              <el-select v-model="formData.orgLevel" placeholder="请选择机构行政级别" clearable :style="{width: '100%'}" :disabled="b_disable">
                <el-option v-for="(item, index) in orgLevel" :key="index" :label="item.label"
                           :value="item.value" ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="机构性质" prop="orgpro">
              <el-select v-model="formData.orgPro" placeholder="请选择机构性质" clearable :style="{width: '100%'}" :disabled="b_disable">
                <el-option v-for="(item, index) in orgPro" :key="index" :label="item.label"
                           :value="item.value" ></el-option>
              </el-select>
            </el-form-item>
          </el-col>

        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="是否参公管理" prop="ifpublicmanage">
              <el-radio-group v-model="formData.ifPublicmanage" size="small">
                <el-radio v-for="(item, index) in ifPublicmanage" :key="index" :label="item.value"
                          :disabled="b_disable">{{item.label}}</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="离退休人数" prop="retirenum">
              <el-input v-model="formData.retireNum" clearable :style="{width: '100%'}" :disabled="b_disable"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="编制人数" prop="zbbnum">
              <el-input v-model="formData.zbbNum" clearable :style="{width: '100%'}" :disabled="b_disable"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="房屋所有权" prop="buildingownership">
              <el-select v-model="formData.buildingOwnership" placeholder="请选择房屋所有权" clearable :style="{width: '100%'}" :disabled="b_disable">
                <el-option v-for="(item, index) in buildingOwnership" :key="index" :label="item.label"
                           :value="item.value" ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="办公用房在建面积（平方米）" prop="officebuildingarea">
              <el-input v-model="formData.officeBuildingarea" clearable :style="{width: '100%'}" :disabled="b_disable"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="办公用房建筑面积（平方米）" prop="officebuildarea">
              <el-input v-model="formData.officeBuildarea" clearable :style="{width: '100%'}" :disabled="b_disable"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="职能科室数" prop="fundivCount">
              <el-input v-model="formData.funDivCount" clearable :style="{width: '100%'}" :disabled="b_disable"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="派出机构数" prop="orgcount">
              <el-input v-model="formData.orgCount" clearable :style="{width: '100%'}" :disabled="b_disable"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="业务科室数" prop="businessdivCount">
              <el-input v-model="formData.businessDivCount" clearable :style="{width: '100%'}" :disabled="b_disable"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="10">
            <el-form-item label="检测仪器设备数（1万以下）" prop="equ1count">
              <el-input v-model="formData.equ1Count"  clearable :style="{width: '80%'}" :disabled="b_disable">
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="7">
            <el-form-item label="（1万到10万）" prop="equ2count">
              <el-input v-model="formData.equ2Count"  clearable :style="{width: '90%'}" :disabled="b_disable">
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="7">
            <el-form-item label="（10万以上）" prop="equ3count">
              <el-input v-model="formData.equ3Count" clearable :style="{width: '90%'}" :disabled="b_disable">
              </el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="汽车数（不含快速检测车）" prop="buscount">
              <el-input v-model="formData.busCount" clearable :style="{width: '90%'}" :disabled="b_disable"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="快速检测车" prop="rapidtestvehiclecount">
              <el-input v-model="formData.rapidtestvehicleCount" clearable :style="{width: '100%'}" :disabled="b_disable"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="摩托车数" prop="motorcount">
              <el-input v-model="formData.motorCount" clearable :style="{width: '100%'}" :disabled="b_disable"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="照相机数" prop="cameracount">
              <el-input v-model="formData.cameraCount" clearable :style="{width: '100%'}" :disabled="b_disable"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="摄像机数" prop="videocount">
              <el-input v-model="formData.videoCount" clearable :style="{width: '100%'}" :disabled="b_disable"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="复印机数" prop="vrcount">
              <el-input v-model="formData.vrcount" clearable :style="{width: '100%'}" :disabled="b_disable"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="台式电脑数" prop="computerNum">
              <el-input v-model="formData.computerNum" clearable :style="{width: '100%'}" :disabled="b_disable"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="笔记本电脑数" prop="notepadNum">
              <el-input v-model="formData.notepadNum" clearable :style="{width: '100%'}" :disabled="b_disable"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="服务机数" prop="serverCount">
              <el-input v-model="formData.serverCount" clearable :style="{width: '100%'}" :disabled="b_disable"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="交换机数" prop="pbxCount">
              <el-input v-model="formData.pbxCount" clearable :style="{width: '100%'}" :disabled="b_disable"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="传真机数" prop="faxCount">
              <el-input v-model="formData.faxCount" clearable :style="{width: '100%'}" :disabled="b_disable"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="投影仪数" prop="ohpCount">
              <el-input v-model="formData.ohpCount" clearable :style="{width: '100%'}" :disabled="b_disable"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="录音笔数" prop="copycatNum">
              <el-input v-model="formData.copycatNum" clearable :style="{width: '100%'}" :disabled="b_disable"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row v-if="!b_disable">
          <el-col :span="12">
            <el-form-item size="large">
              <el-button type="primary" @click="submitupdate">提交</el-button>
              <el-button type="success" @click="backadd">返回</el-button>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row v-else>
          <el-col :span="12">
            <el-button type="primary" @click="b_disable = false">修改</el-button>
            <el-button type="success" @click="backadd">返回</el-button>
          </el-col>
        </el-row>
        <el-row v-else>
        </el-row>
      </el-form>
  </div>
</template>

<script>
  import {post} from "@/utils/api";

  export default {
    props: {
      b_disable: Boolean,
      orgid:Number,
      butt:Boolean
    },
    data() {
      return {
        adType: [{
          "label": "行政部门",
          "value": 1
        }, {
          "label": "卫生监督机构",
          "value": 2
        }, {
          "label": "协作单位",
          "value": "3"
        }], //行政类别
        formData: {},
        areaType: [{
          "label": "省",
          "value": 1
        }, {
          "label": "市",
          "value": 2
        }, {
          "label": "县",
          "value": 3
        }, {
          "label": "区",
          "value": 4
        }],
        orgLevel: [{
          "label": "厅局级",
          "value": 1
        }, {
          "label": "副厅局级",
          "value": 2
        }, {
          "label": "处级",
          "value": 3
        }, {
          "label": "副处级",
          "value": 4
        }, {
          "label": "科级",
          "value": 5
        }, {
          "label": "副科级",
          "value": 6
        }, {
          "label": "副科级以下",
          "value": 7
        }, {
          "label": "未定级",
          "value": 8
        }],
        orgPro: [{
          "label": "行政机构、事业单位",
          "value": 1
        }, {
          "label": "全额拔款事业单位",
          "value": 2
        }, {
          "label": "差额拔款事业单位",
          "value": 3
        }, {
          "label": "自收自支事业单位",
          "value": 4
        }, {
          "label": "其他、空",
          "value": 5
        }],
        ifPublicmanage: [{
          "label": "是",
          "value": 1
        }, {
          "label": "否",
          "value": 2
        }],
        buildingOwnership: [{
          "label": "自有",
          "value": 1
        }, {
          "label": "借",
          "value": 2
        }, {
          "label": "租",
          "value": 3
        }, {
          "label": "空",
          "value": 0
        }],
      }
    },
    created() {

    },
    watch:{
      orgid:{
        handler(newval,oldval){
          this.getbyorg()
        },
        immediate:true
      }
    },
    methods: {
      async getbyorg() {
        let res = await post("/org/getbyid", {id:this.orgid})
        if (res.orgplus.ifPublicmanage == 1)
          res.orgplus.ifPublicmanage = '是'
        if (res.orgplus.ifPublicmanage == 0)
          res.orgplus.ifPublicmanage = '否'
        if (res.orgplus.buildingOwnership == 1)
          res.orgplus.buildingOwnership = '自有'
        if (res.orgplus.buildingOwnership == 2)
          res.orgplus.buildingOwnership = '借'
        if (res.orgplus.buildingOwnership == 3)
          res.orgplus.buildingOwnership = '租'
        if (res.orgplus.buildingOwnership == 0)
          res.orgplus.buildingOwnership = '空'
        if (res.org.exeType == 1)
          res.org.exeType = '卫生监督机构'
        if (res.org.exeType == 2)
          res.org.exeType = '行政部门'
        if (res.org.exeType == 3)
          res.org.exeType = '协作单位'
        if (res.org.areaType == 1)
          res.org.areaType = '省'
        if (res.org.areaType == 2)
          res.org.areaType = '市'
        if (res.org.areaType == 3)
          res.org.areaType = '县级市'
        if (res.org.areaType == 4)
          res.org.areaType = '县'
        if (res.org.areaType == 5)
          res.org.areaType = '区'
        if (res.org.orgLevel == 1)
          res.org.orgLevel = '厅局级'
        if (res.org.orgLevel == 2)
          res.org.orgLevel = '副厅局级'
        if (res.org.orgLevel == 3)
          res.org.orgLevel = '处级'
        if (res.org.orgLevel == 4)
          res.org.orgLevel = '副处级'
        if (res.org.orgLevel == 5)
          res.org.orgLevel = '科级'
        if (res.org.orgLevel == 6)
          res.org.orgLevel = '副科级'
        if (res.org.orgLevel == 7)
          res.org.orgLevel = '副科级以下'
        if (res.org.orgLevel == 8)
          res.org.orgLevel = '未定级'
        if (res.org.orgPro == 1)
          res.org.orgPro = '行政机构，事业单位'
        if (res.org.orgPro == 2)
          res.org.orgPro = '全额拨款事业单位'
        if (res.org.orgPro == 3)
          res.org.orgPro = '差额拨款事业单位'
        if (res.org.orgPro == 4)
          res.org.orgPro = '自收自支事业单位'
        if (res.org.orgPro == 5)
          res.org.orgPro = '其他、空'
        this.formData = {...res.org, ...res.orgplus}
      },

      async submitupdate(){
        this.formData.id = this.orgid
        let date = this.formData
        if (date.ifPublicmanage==='是')
          date.ifPublicmanage = 1
        if (date.ifPublicmanage ==='否')
          date.ifPublicmanage = 0
        if (date.buildingOwnership ==='自有')
          date.buildingOwnership = 1
        if (date.buildingOwnership ==='借')
          date.buildingOwnership =2
        if (date.buildingOwnership ==='租')
          date.buildingOwnership = 3
        if (date.buildingOwnership ==='空')
          date.buildingOwnership = 0
        if (date.exeType ==='卫生监督机构')
          date.exeType = 1
        if (date.exeType ==='行政部门' )
          date.exeType = 2
        if (date.exeType === '协作单位')
          date.exeType = 3
        if (date.areaType ==='省' )
          date.areaType = 1
        if (date.areaType === '市')
          date.areaType = 2
        if (date.areaType === '县级市')
          date.areaType = 3
        if (date.areaType === '县')
          date.areaType = 4
        if (date.areaType === '区')
          date.areaType = 5
        if (date.orgLevel === '厅局级')
          date.orgLevel = 1
        if (date.orgLevel === '副厅局级')
          date.orgLevel = 2
        if (date.orgLevel === '处级')
          date.orgLevel = 3
        if (date.orgLevel === '副处级')
          date.orgLevel = 4
        if (date.orgLevel === '科级')
          date.orgLevel = 5
        if (date.orgLevel === '副科级')
          date.orgLevel = 6
        if (date.orgLevel === '副科级以下')
          date.orgLevel = 7
        if (date.orgLevel === '未定级')
          date.orgLevel = 8
        if (date.orgPro === '行政机构，事业单位')
          date.orgPro = 1
        if (date.orgPro === '全额拨款事业单位')
          date.orgPro = 2
        if (date.orgPro === '差额拨款事业单位')
          date.orgPro = 3
        if (date.orgPro === '自收自支事业单位')
          date.orgPro = 4
        if (date.orgPro === '其他、空')
          res.org.orgPro = 5
        await post("/org/update",date)
        console.log("------")
      },
      update(){
        this.b_disable = false
      },
      backadd() {
        this.$router.back()
      },
      resetForm() {
        this.formData= {}
      },
    }
  }
</script>
<style></style>
